home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2009 December / maximum-cd-2009-12.iso / DiscContents / gimp-2.7.0-i686-setup.exe / {app} / share / gimp / 2.0 / scripts / chip-away.scm < prev    next >
Encoding:
GIMP Script-Fu Script  |  2009-08-19  |  8.0 KB  |  206 lines

  1. ; GIMP - The GNU Image Manipulation Program
  2. ; Copyright (C) 1995 Spencer Kimball and Peter Mattis
  3. ;
  4. ;  Supposed to look vaguely like roughly carved wood. Chipped away if you will.
  5. ;
  6. ;  Options: Text String - the string to make the logo from
  7. ;           Font        - which font to use
  8. ;           Font Size   - how big
  9. ;           Chip Amount - how rought he chipping is (how spread the bump map is)
  10. ;           Blur Amount - the bump layer is blurred slighty by this amount
  11. ;           Invert      - whether or not to invert the bumpmap (gives a carved in feel)
  12. ;           Drop Shadow - whether or not to draw a drop shadow
  13. ;           Keep bump layer? - whether to keep the layer used as the bump map
  14. ;           fill bg with pattern? - whether to fill the background with the pattern or leave it white
  15. ;           Keep Background - whether or not to remove the background layer
  16. ;
  17. ;  Adrian Likins  (Adrian@gimp.org)
  18. ;  Jan 11, 1998 v1
  19. ;
  20. ;  see http://www.gimp.org/~adrian/script.html
  21. ;
  22. ; This program is free software: you can redistribute it and/or modify
  23. ; it under the terms of the GNU General Public License as published by
  24. ; the Free Software Foundation; either version 3 of the License, or
  25. ; (at your option) any later version.
  26. ;
  27. ; This program is distributed in the hope that it will be useful,
  28. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  29. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  30. ; GNU General Public License for more details.
  31. ;
  32. ; You should have received a copy of the GNU General Public License
  33. ; along with this program.  If not, see <http://www.gnu.org/licenses/>.
  34. ;
  35. ;  Some suggested patterns: Dried mud, 3D green, Slate
  36. ;
  37.  
  38. (define (apply-chip-away-logo-effect img
  39.                                      logo-layer
  40.                                      spread-amount
  41.                                      blur-amount
  42.                                      invert
  43.                                      drop-shadow
  44.                                      keep-bump
  45.                                      bg-fill
  46.                                      keep-back
  47.                                      pattern)
  48.   (let* (
  49.         (width (car (gimp-drawable-width logo-layer)))
  50.         (height (car (gimp-drawable-height logo-layer)))
  51.         (bg-layer (car (gimp-layer-new img width height RGB-IMAGE "Background" 100 NORMAL-MODE)))
  52.         (bump-layer (car (gimp-layer-new img width height RGBA-IMAGE "Bump Layer" 100 NORMAL-MODE)))
  53.         )
  54.  
  55.     (gimp-context-push)
  56.  
  57.     (script-fu-util-image-resize-from-layer img logo-layer)
  58.     (script-fu-util-image-add-layers img bump-layer bg-layer)
  59.     (gimp-layer-set-lock-alpha logo-layer TRUE)
  60.     (gimp-context-set-pattern pattern)
  61.  
  62.     (gimp-context-set-background '(255 255 255))
  63.     (gimp-selection-all img)
  64.  
  65.     (if (= bg-fill TRUE)
  66.         (gimp-edit-bucket-fill bg-layer
  67.                                PATTERN-BUCKET-FILL NORMAL-MODE
  68.                                100 255 FALSE 1 1)
  69.         (gimp-edit-fill bg-layer BACKGROUND-FILL)
  70.     )
  71.  
  72.     (gimp-selection-all img)
  73.     (gimp-edit-clear bump-layer)
  74.     (gimp-selection-none img)
  75.     (gimp-selection-layer-alpha logo-layer)
  76.     (gimp-edit-fill bump-layer BACKGROUND-FILL)
  77.     (gimp-edit-bucket-fill logo-layer
  78.                            PATTERN-BUCKET-FILL NORMAL-MODE 100 255 FALSE 1 1)
  79.     (gimp-selection-none img)
  80.  
  81.     (gimp-layer-set-lock-alpha bump-layer FALSE)
  82.     (plug-in-spread RUN-NONINTERACTIVE img bump-layer spread-amount spread-amount)
  83.     (gimp-selection-layer-alpha bump-layer)
  84.     (plug-in-gauss-rle RUN-NONINTERACTIVE img bump-layer blur-amount TRUE TRUE)
  85.  
  86.     (gimp-selection-none img)
  87.  
  88.     (plug-in-bump-map RUN-NONINTERACTIVE img logo-layer bump-layer
  89.                       135.00 25.0 60 0 0 0 0 TRUE invert 1)
  90.  
  91.     (gimp-drawable-set-visible bump-layer FALSE)
  92.  
  93.      (if (= drop-shadow TRUE)
  94.         (begin
  95.           (let* ((shadow-layer (car (gimp-layer-new img width height RGBA-IMAGE "Shadow layer" 100 NORMAL-MODE))))
  96.             (gimp-image-set-active-layer img logo-layer)
  97.             (script-fu-util-image-add-layers img shadow-layer)
  98.             (gimp-selection-all img)
  99.             (gimp-edit-clear shadow-layer)
  100.             (gimp-selection-none img)
  101.             (gimp-selection-layer-alpha logo-layer)
  102.             (gimp-context-set-background '(0 0 0))
  103.             (gimp-edit-fill shadow-layer BACKGROUND-FILL)
  104.             (gimp-selection-none img)
  105.             (plug-in-gauss-rle RUN-NONINTERACTIVE img shadow-layer 5 TRUE TRUE)
  106.             (gimp-layer-translate shadow-layer 6 6))))
  107.  
  108.      (if (= keep-bump FALSE)
  109.          (gimp-image-remove-layer img bump-layer))
  110.  
  111.      (if (= keep-back FALSE)
  112.          (gimp-image-remove-layer img bg-layer))
  113.  
  114.     (gimp-context-pop)
  115.   )
  116. )
  117.  
  118. (define (script-fu-chip-away-logo-alpha img
  119.                                         logo-layer
  120.                                         spread-amount
  121.                                         blur-amount
  122.                                         invert
  123.                                         drop-shadow
  124.                                         keep-bump
  125.                                         bg-fill
  126.                                         keep-back
  127.                                         pattern)
  128.   (begin
  129.     (gimp-image-undo-group-start img)
  130.     (apply-chip-away-logo-effect img logo-layer spread-amount blur-amount
  131.                                  invert drop-shadow keep-bump bg-fill
  132.                                  keep-back pattern)
  133.     (gimp-image-undo-group-end img)
  134.     (gimp-displays-flush)
  135.   )
  136. )
  137.  
  138. (script-fu-register "script-fu-chip-away-logo-alpha"
  139.   _"Chip Awa_y..."
  140.   _"Add a chipped woodcarving effect to the selected region (or alpha)"
  141.   "Adrian Likins <adrian@gimp.org>"
  142.   "Adrian Likins <adrian@gimp.org>"
  143.   "1997"
  144.   "RGBA"
  145.   SF-IMAGE      "Image"                 0
  146.   SF-DRAWABLE   "Drawable"              0
  147.   SF-ADJUSTMENT _"Chip amount"          '(30 0 200 1 10 0 1)
  148.   SF-ADJUSTMENT _"Blur amount"          '(3 1 100 1 10 1 0)
  149.   SF-TOGGLE     _"Invert"               FALSE
  150.   SF-TOGGLE     _"Drop shadow"          TRUE
  151.   SF-TOGGLE     _"Keep bump layer"      FALSE
  152.   SF-TOGGLE     _"Fill BG with pattern" TRUE
  153.   SF-TOGGLE     _"Keep background"      TRUE
  154.   SF-PATTERN    _"Pattern"              "Burlwood"
  155. )
  156.  
  157. (script-fu-menu-register "script-fu-chip-away-logo-alpha"
  158.                          "<Image>/Filters/Alpha to Logo")
  159.  
  160.  
  161. (define (script-fu-chip-away-logo text
  162.                                   font
  163.                                   font-size
  164.                                   spread-amount
  165.                                   blur-amount
  166.                                   invert
  167.                                   drop-shadow
  168.                                   keep-bump
  169.                                   bg-fill
  170.                                   keep-back
  171.                                   pattern)
  172.   (let* ((img (car (gimp-image-new 256 256 RGB)))
  173.          (text-layer (car (gimp-text-fontname img -1 0 0
  174.                                      text 30 TRUE font-size PIXELS font))))
  175.     (gimp-image-undo-disable img)
  176.     (apply-chip-away-logo-effect img text-layer spread-amount blur-amount
  177.                                  invert drop-shadow keep-bump bg-fill
  178.                                  keep-back pattern)
  179.     (gimp-image-undo-enable img)
  180.     (gimp-display-new img)
  181.   )
  182. )
  183.  
  184. (script-fu-register "script-fu-chip-away-logo"
  185.   _"Chip Awa_y..."
  186.   _"Create a logo resembling a chipped wood carving"
  187.   "Adrian Likins <adrian@gimp.org>"
  188.   "Adrian Likins <adrian@gimp.org>"
  189.   "1997"
  190.   ""
  191.   SF-STRING     _"Text"                 "Sloth"
  192.   SF-FONT       _"Font"                 "RoostHeavy"
  193.   SF-ADJUSTMENT _"Font size (pixels)"   '(200 2 1000 1 10 0 1)
  194.   SF-ADJUSTMENT _"Chip amount"          '(30 0 200 1 10 0 1)
  195.   SF-ADJUSTMENT _"Blur amount"          '(3 1 100 1 10 1 0)
  196.   SF-TOGGLE     _"Invert"               FALSE
  197.   SF-TOGGLE     _"Drop shadow"          TRUE
  198.   SF-TOGGLE     _"Keep bump layer"      FALSE
  199.   SF-TOGGLE     _"Fill BG with pattern" TRUE
  200.   SF-TOGGLE     _"Keep background"      TRUE
  201.   SF-PATTERN    _"Pattern"              "Burlwood"
  202. )
  203.  
  204. (script-fu-menu-register "script-fu-chip-away-logo"
  205.                          "<Image>/File/Create/Logos")
  206.